<template>
  <div class="app-container">
    <div class="Header">
      <edit-form ref="filterContainer" v-show="showSearch" :editFormMap="filterMap" :editFormData="queryParams" @getFormOptionListMap="getFormOptionListMap">
        <template slot="buttonGroup">
          <el-col :span="4">
            <el-form-item class="buttonGroup">
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-col>
        </template>
      </edit-form>
      <handle-button-group
        :showSearch.sync="showSearch"
        :single="single"
        :multiple="multiple"
        :authModule="{ module: 'meet', name: 'request' }"
        :btnAuth="{ add: false, edit: false, delete: true, export: true }"
        @handleAdd="handleAdd"
        @handleUpdate="handleUpdate"
        @handleDelete="handleDelete"
        @handleExport="handleExport"
        @getList="getList"
      />
    </div>
    <table-list
      ref="tableListContainer"
      :tableListMap="tableMap"
      :request="{
        apiKey: 'meetRequestList',
        params: queryParams,
        method: 'get',
      }"
      @selection-change="handleSelectionChange"
      @changeTableListAction="
        (TableList) => {
          list = TableList;
        }
      "
    >
      <template slot="hasSelect">
        <el-table-column type="selection" width="55" :align="'center'" />
      </template>
      <template slot="hasHandle">
        <el-table-column label="操作" :align="'center'">
          <template slot-scope="scope">
            <!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['meet:request:edit']">修改</el-button> -->
            <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['meet:request:remove']">删除</el-button>
          </template>
        </el-table-column>
      </template>
    </table-list>

  </div>
</template>

<script>
import * as api from '@/api/meet/request';
import { getDataSource } from '@/static/js/dataSource';

export default {
  name: 'Request',
  computed: {
    filterMap() {
			return getDataSource('editForm', 'requestFilterMap');
		},
		tableMap() {
			return getDataSource('tableColumn', 'requestTableMap');
		},
  },
  data() {
    return {
      // 当前页面
      pageTitle: '见面请求管理',
      optionListMap: {},
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 表格数据
      list: [],
      // 下拉数据对象
      tableOptionMap: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {},
      // 表单参数
      basicForm: {},
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.$nextTick(() => {
        this.$refs.tableListContainer.init();
      });
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.basicForm = this.$options.data().basicForm;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      const tableListContainer = this.$refs.tableListContainer;
      tableListContainer.pagination = tableListContainer.$options.data().pagination;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      const filterContainer = this.$refs.filterContainer;
      filterContainer.resetForm('editFormData');
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.open = true;
      this.title = `添加${this.pageTitle}`;
      this.$nextTick(() => {
        this.reset();
        const editFormContainer = this.$refs.editFormContainer;
        const editFormData = editFormContainer.$refs.editFormData;
        editFormData.resetFields();
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row ? row.id : this.ids.join(',');
      this.$modal
        .confirm('是否确认删除编号为"' + ids + '"的数据项？')
        .then(function () {
          return api.delItem(ids);
        })
        .then(() => {
          this.getList();
          this.$message.success('删除成功');
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const tableListContainer = this.$refs.tableListContainer;
      const pagination = tableListContainer.pagination;
      const params = {
        ...pagination,
        ...this.queryParams,
      };
      api.exportExcel(params, `${this.pageTitle}数据导出`);
    },
    getFormOptionListMap() {
    },
    /** 提交按钮 */
    submitForm() {
    },
  },
};
</script>
<style lang="scss" scoped></style>
